<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../Vue全家桶_stu/03_依赖包/vue.js"></script>
</head>

<body>
    <!-- 键盘修饰符用于 keydown|keyup事件  也可以链式调用-->
    <div id="root">
        <!-- 当按下enter才触发handler -->
        <input type="text" @keydown.enter="handler" placeholder="按下回车触发">
        <!-- 当按下w键才触发 -->
        <input type="text" @keydown.w="handler" placeholder="按下w键触发">
        <!-- 当按下ctrl+c时才触发 -->
        <input type="text" @keydown.Ctrl.c="handler" placeholder="按下ctrl+c触发">
    </div>
    <script>
        const vm = new Vue({
            el: '#root',
            methods: {
                handler(event) {
                    console.log('回调触发')
                    console.log(event.keyCode)
                }
            }
        })
    </script>
</body>

</html>